﻿#ifndef UDPCLIENT_H
#define UDPCLIENT_H

#include <QObject>
#include <QUdpSocket>
#include <QThread>
#include <QByteArray>

#include "pluginJsonData.h"

class UdpClient : public QObject
{
    Q_OBJECT
public:
    explicit UdpClient(QObject *parent = nullptr);
    ~UdpClient();

    void bindNetwork(const QString& ip = "127.0.0.1",const int port = 9215);
    void abortNetword();

signals:
    void sendMessage(const QString&);
    void sendPluginData(PluginCommand,const QString& pluginName,const QVariant& variant);

protected:
    void RecvDataFromNetwork();

    void ParseAndPutData(QByteArray&);
private:
    QUdpSocket* socket_;

    QByteArray array_cache_;

    bool is_abort = false;
};

#endif // UDPCLIENT_H
